package com.Ajou.Talky2;

import android.app.*;
import android.content.*;
import android.database.*;
import android.database.sqlite.*;
import android.os.*;
import android.widget.*;

public class FriendList extends Activity {
	ProductDBHelper mHelper;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.friendlist);
		
		mHelper = new ProductDBHelper(this);
		Cursor cursor;
		SQLiteDatabase db = mHelper.getWritableDatabase();

		cursor = db.rawQuery("SELECT * FROM FriendList", null);
		startManagingCursor(cursor);

		SimpleCursorAdapter Adapter = null;
		Adapter = new SimpleCursorAdapter(this, 
				android.R.layout.simple_list_item_2,
				cursor, new String[] { "userName", "phoneNum" }, 
				new int[] { android.R.id.text1, android.R.id.text2});
		ListView list = (ListView)findViewById(R.id.list);
        list.setAdapter(Adapter);
	}
}

class ProductDBHelper extends SQLiteOpenHelper {
	public ProductDBHelper(Context context) {
		super(context, "allad.db", null, 1);
	}

	public void onCreate(SQLiteDatabase db) {
//		db.execSQL("CREATE TABLE product ( _id INTEGER PRIMARY KEY AUTOINCREMENT, " +
//			"User TEXT, price INTEGER);");
//		db.execSQL("INSERT INTO product VALUES (null, '111', 900);");
	}

	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//		db.execSQL("DROP TABLE IF EXISTS product");
//		onCreate(db);
	}
}
